//
//  HRFunChatCell.m
//  Hear
//
//  Created by mac on 2017/8/4.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "HRFunChatCell.h"
#import "HRFunChatModel.h"
#import "NSMutableAttributedString+GDAttString.h"

@interface HRFunChatCell ()
@property(nonatomic, strong)UILabel *titleLabel;
@property (nonatomic, strong)UIView *backView;
@property(nonatomic, strong)UILabel *leftCirlceLabel;
@property(nonatomic, strong)UILabel *rightCirlceLabel;
@end
@implementation HRFunChatCell
-(void)setBackCorlor:(UIColor *)backCorlor{
    self.backView.backgroundColor = backCorlor;
    
    self.leftCirlceLabel.backgroundColor = backCorlor;
    
    self.rightCirlceLabel.backgroundColor = backCorlor;
}

-(void)setFunChatFrameModel:(HRFunChatFrameModel *)funChatFrameModel{
    HRFunChatModel *funChatModel = funChatFrameModel.funModel;
    
    self.backView.frame = funChatFrameModel.backViewRect;
    
    self.titleLabel.frame = funChatFrameModel.titleLabelRect;
    
    self.leftCirlceLabel.frame = CGRectMake(self.backView.left-4, self.backView.top+(self.backView.height-8)/2, 8, 8);
    self.leftCirlceLabel.centerY = self.backView.centerY;
    self.rightCirlceLabel.frame = CGRectMake(self.backView.right-4, self.leftCirlceLabel.top, 8, 8);

    
    self.titleLabel.attributedText = [NSMutableAttributedString attStringFromTextForChatting:funChatModel.TopicTitle textFont:CustomUIFont(14)];
    
}

+(instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *cellID = @"HRFunChatCell";
    
    HRFunChatCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if(!cell){
        cell = [[HRFunChatCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor = [UIColor clearColor];
        
        self.backView = [UIView new];
        self.backView.backgroundColor = [UIColor whiteColor];
        self.backView.layer.cornerRadius = 5;
        self.backView.clipsToBounds = YES;
        [self addSubview:self.backView];

        self.titleLabel = [UILabel new];
        self.titleLabel.numberOfLines = 0;
        self.titleLabel.font = CustomUIFont(13);
        self.titleLabel.textColor =FirstTextColor;
        [self.backView addSubview:self.titleLabel];
        
        
        self.leftCirlceLabel = [UILabel new];
        [self  addSubview:self.leftCirlceLabel];
        self.leftCirlceLabel.layer.cornerRadius = 4;
        self.leftCirlceLabel.clipsToBounds = YES;
        
        self.leftCirlceLabel.layer.borderWidth = 1;
        self.leftCirlceLabel.layer.borderColor = [UIColor blackColor].CGColor;
        
        self.rightCirlceLabel = [UILabel new];
        [self  addSubview:self.rightCirlceLabel];
        self.rightCirlceLabel.layer.cornerRadius = 4;
        self.rightCirlceLabel.clipsToBounds = YES;
        self.rightCirlceLabel.layer.borderWidth = 1;
        self.rightCirlceLabel.layer.borderColor = [UIColor blackColor].CGColor;
    }
    return self;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
